package od.igor.petrov.utils;

/* ================================== *
 *      SORTING BY ID AND ORDER
 * ================================== */

import java.util.Comparator;

public class TestTableBeanIdComparator implements Comparator<TestTableBean> {

	public TestTableBeanIdComparator(boolean orderDesc){
		this.orderDesc = orderDesc;
	}
	
	public int compare(TestTableBean bean1, TestTableBean bean2) {
		int firstBeanId = bean1.getId();
		int secondBeanId = bean2.getId();
		if(firstBeanId > secondBeanId && orderDesc){
			return 1;
		} else if(firstBeanId > secondBeanId && !orderDesc){
			return -1;
		} else {
			return 0;
		}
	}
	
	private boolean orderDesc = false;
}
